﻿package  {
	import flash.utils.Timer;
	import flash.events.TimerEvent;
	import fl.controls.Label;
	
	public class TFPSInspector {
		private var _FPS: int = 0;
		private var _label: Label;
		private var timer: Timer = new Timer(1000);

		public function TFPSInspector(label: Label) {
			_label = label;
			timer.addEventListener(TimerEvent.TIMER, OnTimer);
			timer.start();
		}
		
		private function OnTimer(event: TimerEvent) {
			_label.text = "FPS: " + FPS;
			_FPS = 0;
		}
		
		public function NewFrame() {
			_FPS = _FPS + 1;
		}
		
		public function get FPS(): int {
			return _FPS;
		}
		
		public function Destroy() {
			timer.stop();
			timer = null;
		}

	}
	
}
